<div ng-controller="TasksController">
  <div ng-if="$ctrl.pendingTasks(tasks()).length">
    <div class="results-status">
      <span class="fa fa-clock-o text-muted" aria-hidden="true"></span>
      <span class="sr-only">Pending</span>
      <div class="results-message">
        <h1 class="h3">
          <span ng-if="$ctrl.kind">{{$ctrl.kind | humanizeKind | upperFirst}}</span>
          <strong>{{$ctrl.name}}</strong> is being {{$ctrl.actionLabel}}<span ng-if="$ctrl.showProjectName && $ctrl.projectName"> in <strong>{{$ctrl.projectName}}</strong></span>.
        </h1>
      </div>
    </div>
  </div>
  <div class="results-failure" ng-if="!$ctrl.pendingTasks(tasks()).length && $ctrl.erroredTasks(tasks()).length">
    <div class="results-status">
      <span class="pficon pficon-error-circle-o text-danger" aria-hidden="true"></span>
      <span class="sr-only">Error</span>
      <div class="results-message">
        <h1 class="h3">
          <span ng-if="$ctrl.kind">{{$ctrl.kind | humanizeKind | upperFirst}}</span>
          <strong>{{$ctrl.name}}</strong> failed to be {{$ctrl.actionLabel}}<span ng-if="$ctrl.showProjectName && $ctrl.projectName"> in <strong>{{$ctrl.projectName}}</strong></span>.
        </h1>
      </div>
    </div>
  </div>
  <!-- Import YAML of a single resource. -->
  <div ng-if="!tasks().length">
    <div class="results-status">
      <span class="pficon pficon-ok" aria-hidden="true"></span>
      <span class="sr-only">Success</span>
      <div class="results-message">
        <h1 class="h3">
          <span ng-if="$ctrl.kind">{{$ctrl.kind | humanizeKind | upperFirst}}</span>
          <strong>{{$ctrl.name}}</strong> has been {{$ctrl.actionLabel}}<span ng-if="$ctrl.showProjectName && $ctrl.projectName"> in <strong>{{$ctrl.projectName}}</strong> successfully</span>.
        </h1>
      </div>
    </div>
  </div>
  <div ng-if="tasks().length && $ctrl.allTasksSuccessful(tasks())">
    <div class="results-status">
      <span class="pficon pficon-ok" aria-hidden="true"></span>
      <span class="sr-only">Success</span>
      <div class="results-message">
        <h1 class="h3">
          <span ng-if="$ctrl.kind">{{$ctrl.kind | humanizeKind | upperFirst}}</span>
          <strong>{{$ctrl.name}}</strong> has been {{$ctrl.actionLabel}}<span ng-if="$ctrl.showProjectName && $ctrl.projectName"> in <strong>{{$ctrl.projectName}}</strong> successfully</span>.
        </h1>
      </div>
    </div>
  </div>

  <p ng-if="!$ctrl.pendingTasks(tasks()).length && !$ctrl.erroredTasks(tasks()).length">
    <a href="" ng-click="$ctrl.goToOverview()">Continue to the project overview</a>.
  </p>

  <div ng-if="hasTaskWithError()">
    <ul ng-repeat="task in tasks()">
      <li ng-repeat="alert in task.alerts" ng-if="alert.type === 'error' || alert.type === 'warning'">
        {{alert.message}}
        {{alert.details}}
      </li>
    </ul>
  </div>
</div>

<div class="alert alert-info template-message" ng-if="$ctrl.templateMessage.length">
  <span class="pficon pficon-info" aria-hidden="true"></span>
  <div class="resource-description" ng-bind-html="$ctrl.templateMessage | linkify : '_blank'"></div>
</div>

<div ng-if="$ctrl.createdBuildConfig">
  <h2 class="h3">Making code changes</h2>
  <p ng-if="$ctrl.fromSampleRepo">
    You are set up to use the example git repository. If you would like to modify the source code, fork the <osc-git-link uri="$ctrl.createdBuildConfig.spec.source.git.uri">{{$ctrl.createdBuildConfig.spec.source.git.uri}}</osc-git-link> repository to an OpenShift-visible git account and <a href="{{$ctrl.createdBuildConfig | editResourceURL}}">edit the <strong>{{$ctrl.createdBuildConfig.metadata.name}}</strong> build config</a> to point to your fork.
    <span ng-if="$ctrl.createdBuildConfigWithConfigChangeTrigger()">Note that this will start a new build.</span>
  </p>
  <div ng-repeat="trigger in $ctrl.createdBuildConfig.spec.triggers" ng-if="trigger.type == 'GitHub'">
    <p>
      A GitHub <a target="_blank" href="{{'webhooks' | helpLink}}">webhook trigger</a> has been created for the <strong>{{$ctrl.createdBuildConfig.metadata.name}}</strong> build config.
    </p>
    <p ng-if="$ctrl.fromSampleRepo">
      You can configure the webhook in the forked repository's settings, using the following payload URL:
    </p>
    <p ng-if="!$ctrl.fromSampleRepo">
      <span ng-if="$ctrl.createdBuildConfig.spec.source.git.uri | isGithubLink">
        You can now set up the webhook in the GitHub repository settings if you own it, in <a target="_blank" class="word-break" href="{{$ctrl.createdBuildConfig.spec.source.git.uri | githubLink}}/settings/hooks">{{$ctrl.createdBuildConfig.spec.source.git.uri | githubLink}}/settings/hooks</a>, using the following payload URL and specifying a <i>Content type</i> of <code>application/json</code>:
      </span>
      <span ng-if="!($ctrl.createdBuildConfig.spec.source.git.uri | isGithubLink)">
        Your source does not appear to be a URL to a GitHub repository.  If you have a GitHub repository that you want to trigger this build from then use the following payload URL and specifying a <i>Content type</i> of <code>application/json</code>:
      </span>
    </p>
    <copy-to-clipboard clipboard-text="$ctrl.createdBuildConfig.metadata.name | webhookURL : trigger.type : trigger.github.secret : $ctrl.projectName"></copy-to-clipboard>
  </div>
</div>

<div ng-if="$ctrl.parameters.all.length">
  <h2 class="h3">Applied Parameter Values</h2>
  <p>These parameters often include things like passwords. If you will need to reference these values later, copy them to a safe location.
    <span ng-if="$ctrl.parameters.generated.length > 1">Parameters <span ng-repeat="paramName in $ctrl.parameters.generated">{{paramName}}<span ng-if="!$last">, </span></span> were generated automatically.</span>
    <span ng-if="$ctrl.parameters.generated.length === 1">Parameter {{$ctrl.parameters.generated[0]}} was generated automatically.</span>
  </p>
  <div ng-if="!$ctrl.showParamsTable" class="center">
    <a href="" ng-click="$ctrl.toggleParamsTable()">Show parameter values</a>
  </div>
  <key-value-editor
    ng-if="$ctrl.showParamsTable"
    entries="$ctrl.parameters.all"
    key-placeholder="Name"
    value-placeholder="Value"
    cannot-add
    cannot-delete
    cannot-sort
    show-header
    is-readonly></key-value-editor>
</div>
